package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.entity.OwnDebitDetail;
import com.chainyoung.component_tmperson.entity.OwnWalletDebit;
import com.chainyoung.component_tmperson.ui.mvp.contract.OwnWalletDebitContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.OwnWalletDebitDetailContract;

import java.util.TreeMap;

import javax.inject.Inject;

public class OwnWalletDebitDetailPresenter extends BasePresenter<OwnWalletDebitDetailContract.Model, OwnWalletDebitDetailContract.View> {

    @Inject
    public OwnWalletDebitDetailPresenter(OwnWalletDebitDetailContract.Model model, OwnWalletDebitDetailContract.View rootView) {
        super(model, rootView);
    }


    public void getDebitDetail(TreeMap<String, Object> map) {

        addSubscribe(mModel.getDebitDetail(map)
                .compose(RxUtils.<OwnDebitDetail>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<OwnDebitDetail>(mView, true) {
                    @Override
                    public void onNext(OwnDebitDetail data) {
                        mView.onGetOwnWalletDebitDetailSuccessed(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.onGetOwnWalletDebitDetailFailed();
                        super.onError(e);
                    }
                }));
    }

}






